<?php


namespace app\admin\model;


class ProductSynthesisLogModel extends BaseModel
{
    protected $name='product_synthesis_log';

    public static function saveDataLog($poid,$array=[]){
       $info = PurchaseProductOrderModel::where(['po_id'=>$poid])->find();

       if ($info['match_actual']==0){
           $match_actual = $array['match_actual'];
           $match_not = $array['match_not'];
           $match_usable = $array['match_usable'];
       }else{
           $match_actual =  $array['match_actual']-$info['match_actual'];
           $match_not =  $array['match_not'];// - $info['match_actual'];
           $match_usable = $array['match_usable'];//$array['match_usable'] -$info['match_usable'];
       }
       $log=[
           'po_id'=>$info['po_id'],
           'purchase_id'=>$info['purchase_id'],
           'pro_id'=>$info['pro_id'],
           'total_num'=>$info['total_num'],
           'total_price'=>$info['total_price'],
           'cost_unit_price'=>$info['cost_unit_price'],
           'match_actual'=>$match_actual,
           'match_not'=>$match_not,
           'match_usable'=>$match_usable,
           'storage_location'=>$info['storage_location'],
           'application_total'=>$info['application_total'],
           'remark'=>$info['remark'],
           'create_time'=>time(),
       ];
        self::insertGetId($log);
    }

}